Skip to content

Conversation

@lukel97
Copy link
Contributor

@lukel97 lukel97 commented May 28, 2025

This is a follow up from #141300 (comment)

This is a follow up from llvm#141300 (comment)

An undef mask element in a shufflevector is really poison, so explicitly match it here for clarity.
@lukel97 lukel97 requested a review from nikic as a code owner May 28, 2025 10:52
@lukel97 lukel97 requested a review from dtcxzyw May 28, 2025 10:52
@llvmbot llvmbot added llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms labels May 28, 2025
@lukel97 lukel97 changed the title [InstCombine] Explicitly match poison mask. NFCI [InstCombine] Explicitly match poison operand. NFCI May 28, 2025
@llvmbot
Copy link
Member

llvmbot commented May 28, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Luke Lau (lukel97)

Changes

This is a follow up from #141300 (comment)

An undef mask element in a shufflevector is really poison, so explicitly match it here for clarity.


Full diff: https://github.com/llvm/llvm-project/pull/141744.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp (+2-2)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index e01dafd36d30d..e101edf4a6208 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1422,7 +1422,7 @@ InstCombinerImpl::foldShuffledIntrinsicOperands(IntrinsicInst *II) {
   ArrayRef<int> Mask;
   auto *NonConstArg = find_if_not(II->args(), IsaPred<Constant>);
   if (!NonConstArg ||
-      !match(NonConstArg, m_Shuffle(m_Value(X), m_Undef(), m_Mask(Mask))))
+      !match(NonConstArg, m_Shuffle(m_Value(X), m_Poison(), m_Mask(Mask))))
     return nullptr;
 
   // At least 1 operand must have 1 use because we are creating 2 instructions.
@@ -1433,7 +1433,7 @@ InstCombinerImpl::foldShuffledIntrinsicOperands(IntrinsicInst *II) {
   SmallVector<Value *, 4> NewArgs;
   Type *SrcTy = X->getType();
   for (Value *Arg : II->args()) {
-    if (match(Arg, m_Shuffle(m_Value(X), m_Undef(), m_SpecificMask(Mask))) &&
+    if (match(Arg, m_Shuffle(m_Value(X), m_Poison(), m_SpecificMask(Mask))) &&
         X->getType() == SrcTy)
       NewArgs.push_back(X);
     else if (match(Arg, m_ImmConstant(C))) {

@lukel97 lukel97 merged commit 618a399 into llvm:main May 28, 2025
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants